package service

import (
	"myserver/dao"
	"myserver/model"
	"myserver/param"
	"myserver/tool"
)

type FamilyService struct {
}

func (s *FamilyService) GetFamily(id string) model.Family {
	var familyDao = dao.FamilyDao{MyOrm: tool.MyDb}
	var family model.Family = familyDao.GetFamily(id)
	return family
}

func (s *FamilyService) CreateFamily(family model.Family) int64 {
	var familyDao = dao.FamilyDao{MyOrm: tool.MyDb}
	res := familyDao.CreateFamily(family)
	return res
}

func (s *FamilyService) DeleteFamily(family model.Family) int64 {
	var familyDao = dao.FamilyDao{MyOrm: tool.MyDb}
	res := familyDao.DeleteFamily(family)
	return res
}

func (s *FamilyService) UpdateFamily(family model.Family) int64 {
	var familyDao = dao.FamilyDao{MyOrm: tool.MyDb}
	res := familyDao.UpdateFamily(family)
	return res
}

func (s *FamilyService) GetFamilyPage(pageParam param.PageParam) param.ResponsePageParam {
	var familyDao = dao.FamilyDao{MyOrm: tool.MyDb}
	pageParam.Page = pageParam.Limit * (pageParam.Page - 1)
	res := familyDao.GetFamilyPage(pageParam)
	return res
}
